package com.zzx.service;

import com.github.pagehelper.ISelect;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zzx.bean.Bill;
import com.zzx.dao.BillDao;
import org.apache.catalina.LifecycleState;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2020-10-22 15:56
 * @Modified By:
 */
@Service
public class BillService {

    @Resource
    private BillDao billDao;

    public List<Bill> list(Bill bill){
        return billDao.myList(bill);
    }

    public Bill get(Long id){
        return billDao.selectByPrimaryKey(id);
    }

    public int add(Bill bill){
        return billDao.insert(bill);
    }

    public int update(Bill bill){
        return billDao.updateByPrimaryKey(bill);
    }

    public int delete(Long id){
        return billDao.deleteByPrimaryKey(id);
    }

    public PageInfo<Bill> listPage(Bill bill,int pageNum, int pageSize){
        return PageHelper.startPage(pageNum,pageSize).doSelectPageInfo(() -> {
            billDao.myList(bill);
        });
    }
}
